
layui.use(['form', 'layedit', 'laydate'], function () {
    var form = layui.form
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;
			
			
			
			            laydate.render({
                elem: '#newsPublishtime'
            });
		
			            laydate.render({
                elem: '#updateTime'
            });
		
	    form.verify({
			hotspotsId: function(value) {
        if (value.length > 64) {
            return '长度不能大于64';
        }
		            if (value.length == "") {
                return '必填项不能为空';
            }
		    },
			newsId: function(value) {
        if (value.length > 64) {
            return '长度不能大于64';
        }
		            if (value.length == "") {
                return '必填项不能为空';
            }
		    },
			newsScore: function(value) {
        if (value.length > 22) {
            return '长度不能大于22';
        }
		            if (value.length == "") {
                return '必填项不能为空';
            }
		    },
			newsPublishtime: function(value) {
        if (value.length > 7) {
            return '长度不能大于7';
        }
		            if (value.length == "") {
                return '必填项不能为空';
            }
		    },
			updateTime: function(value) {
        if (value.length > 7) {
            return '长度不能大于7';
        }
		            if (value.length == "") {
                return '必填项不能为空';
            }
		    },
	
});
    //监听提交
    form.on('submit(formDemo)', function (data) {
        $ = layui.jquery;
        layer=layui.layer;
        var waitIndex='';

        $.ajax({
            url: "/cmsservice/newsHotspotsController/update",
            type:"POST",
            data: data.field,
            dataType:'json',
            beforeSend:function () {
                waitIndex=layer.load();//删除前打开遮挡层
            },
            success: function(returnData){
                if(returnData.code==500){
                    layer.msg(returnData.message,{icon:2,time:1500,shade: 0.1},function () {
                    });

                }else{
                    layer.msg(returnData.message,{icon:1,time:1500,shade: 0.1},function () {
                        top.winui.window.close('edit');
                    });

                }


            },complete:function () {
                layer.close(waitIndex);
            }
        });

        return false;
    });
});